package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.result.ListResult;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.ArticleInfoService;
import javax.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName:ArticleInfoController
 * @功能：
 * @author：wlei
 * @日期：2022/9/3-18:19
 **/
@RestController
@Slf4j
@RequestMapping("/v1/articleinfo/")
public class ArticleInfoController extends BaseController {

    @Autowired
    private ArticleInfoService articleInfoService;

    @PostMapping("create")
    public JsonObj create(HttpServletResponse response) {
        return articleInfoService.createArticleInfo(getPageData());
    }

    @PostMapping("update")
    public JsonObj update(HttpServletResponse response) {
        return articleInfoService.updateArticleInfo(getPageData());
    }

    @PostMapping("deleteById")
    public JsonObj deleteById(HttpServletResponse response) {
        return articleInfoService.deleteById(getPageData());
    }

    @GetMapping("listLatestArticles")
    public JsonObj listLatestArticles(HttpServletResponse response) {
        return articleInfoService.listLatestArticles(getPageData());
    }

    @GetMapping("listByPage")
    public ListResult<Object> listByPage(HttpServletResponse response) {
        return articleInfoService.listByPage(getPageData());
    }


}
